Skip to content

Setup counts a ~/ import of AGENTS.md under any spelling of the home folder - #2038

Open
zlareb1 wants to merge 8 commits into
mainfrom
fix/agent-instructions-real-path
Open

zlareb1 wants to merge 8 commits into
mainfrom
fix/agent-instructions-real-path

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Closes: #2032
Related: #2030

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

In a checkout below a CLAUDE.md that imports AGENTS.md through ~/, loom-setup no longer adds a CLAUDE.md, and the session-start notice and status check no longer call the AGENTS.md block unread, when HOME names the home folder other than as the file system spells it, such as in other letter case.

Why

#2032 reported that setup writes a CLAUDE.md holding only @AGENTS.md when HOME, USERPROFILE or CLAUDE_CONFIG_DIR spells the home or configuration folder other than as the file system names it. Claude Code also leaves AGENTS.md unread under such a spelling, so that import is the one it needs. On macOS, with Claude Code 2.1.334, a checkout under the home folder, text in ~/.claude/CLAUDE.md and an AGENTS.md at the root holding a marker word, claude -p asked for the marker without reading any file:

Environment Marker
HOME=/Users/<name> found
HOME=/USERS/<NAME> none
CLAUDE_CONFIG_DIR=/USERS/<NAME>/.claude none
HOME=/USERS/<NAME>, CLAUDE.md at the root holding @AGENTS.md found
HOME=/USERS/<NAME>, a CLAUDE.md above the checkout holding @~/<dir>/checkout/AGENTS.md found

The client knows its own CLAUDE.md by the spelling it is given. Under another spelling it reads that file as one above the checkout and leaves AGENTS.md unread. agentsUnreadFor in lib/agent-instructions.mjs keeps that spelling (real(), the JavaScript fs.realpathSync, which keeps letter case and an 8.3 name), so setup's answer was right. A comment there now says why. An earlier commit on this branch had replaced it with realPath, which would have left the block in an AGENTS.md the client does not read.

The bug is in imports(). A CLAUDE.md above the checkout that imports AGENTS.md through ~/ counts as reading it. ~/ expands to HOME as given, and real() kept that spelling, while the target is named as the checkout's root is (realPath, through gitToplevel). So under another spelling of HOME the import went unseen: setup added a CLAUDE.md the client did not need, and the session-start notice and loom-client-status, which read the same agentsUnreadFor result, called the block unread. The client reads an import under any spelling of its path, so imports() now names both sides with realPath, and names its target once.

Scope and risk

  • lib/agent-instructions.mjs, its Codex copy (synced), and both plugin manifests at 1.2.162, which no other open pull request uses.
  • realPath never throws, and SessionStart and the status check read the same agentsUnreadFor result as setup, so the change reaches them with no new failure path.
  • The test file's scratch() returns realPath of the new folder, so every setup test spells its folders as setup does; The setup tests pass on Windows, where the temp folder has an 8.3 name #2030's realScratch helper is folded into it. The check for a CLAUDE.md above the temporary folder walks that same spelling alone.
  • Windows was not checked against the client. For the configuration folder's file the plugin keeps the spelling there as it did, so that answer is unchanged. For a ~/ import, realPath now expands an 8.3 USERPROFILE and a drive letter's case, so such an import counts as reading AGENTS.md there too, which the macOS run shows for letter case.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none. Installed clients get the fix through plugin 1.2.162.
  • Rollback: revert; setup files written meanwhile stay as they are.

Tests

  • New agent-instructions.test.mjs test: the home folder as created, and its upper- and lower-cased spellings where the file system holds them (macOS and Windows; the lower case also lowers a drive letter). With the configuration folder named through HOME and through CLAUDE_CONFIG_DIR, the spelling as created gets the block in AGENTS.md and no CLAUDE.md, and another spelling gets the @AGENTS.md import. With a CLAUDE.md above the checkout importing ~/work/checkout/AGENTS.md, every spelling gets the block in AGENTS.md and no CLAUDE.md. On Linux the spelling as created runs alone.
  • On macOS all 35 tests in the file pass, none skipped. Comparing the configuration file through realPath fails the new test, and so does main's imports().
  • tests/unit/test_codex_plugin.py, test_agent_plugin.py, test_plugin_checkout_bytes.py, test_session_content_senders.py, test_doc_links.py and test_public_copy.py, biome, and make format-check lint pass.
  • docs/features/integrations/claude-code.md says the client knows its own CLAUDE.md by the spelling it is given and counts a ~/ or whole-path import.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (Claude Code): ran Claude Code under each spelling of HOME and CLAUDE_CONFIG_DIR to see which instruction files it loads, traced the comparisons in agentsUnreadFor and imports, and ran the test against both mutants.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the Codex plugin copy (python -m scripts.codegen.agent_plugin_sync); the standalone skills are unchanged.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited: none.
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version, and no other open PR uses that version: 1.2.162.
  • The frontend builds and its tests pass, if frontend/ changed: not changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

🤖 Generated with Claude Code


Note

Low Risk
Localized path-normalization in instruction setup; broader realPath use on imports may affect edge cases on Windows but aligns with observed Claude Code behavior.

Overview
Fixes loom-setup and instruction status when HOME, USERPROFILE, or CLAUDE_CONFIG_DIR spell paths differently from the filesystem (e.g. alternate letter case on macOS). Setup no longer spuriously adds a root CLAUDE.md with only @AGENTS.md, and session-start / status no longer mark the block unread when a parent CLAUDE.md already imports AGENTS.md via ~/.

imports() now compares both sides through a configurable normalizer: realPath for “does this import reach AGENTS.md?” (matches Claude Code’s case-insensitive ~/ resolution), and asWritten (renamed from real) for the user config CLAUDE.md vs parent-folder files and for in-repo @agents.md vs AGENTS.md on case-folding volumes.

Docs describe config-folder spelling and import forms; plugin versions bump to 1.2.162 (Claude + Codex). Tests cover alternate home spellings and case-folded import targets.

Reviewed by Cursor Bugbot for commit 5bba514. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 3, 2026 11:31am UTC
loom-telemetry Ready Ready Preview Dec 3, 2026 11:31am UTC

Request Review

@zlareb1
zlareb1 force-pushed the fix/agent-instructions-real-path branch from 45ed539 to 64f7e62 Compare December 2, 2026 17:06
@zlareb1
zlareb1 marked this pull request as draft December 2, 2026 17:22
@zlareb1 zlareb1 changed the title Setup names a home folder spelled another way as the checkout's root does Setup counts a ~/ import of AGENTS.md under any spelling of the home folder Dec 2, 2026
zlareb1 and others added 4 commits December 3, 2026 15:48
…does

agent-instructions compared paths through the JavaScript realpathSync,
which keeps a Windows 8.3 name and letter case, while the checkout root
comes through realPath. A configuration folder or `~/` import spelled
another way then missed, and setup wrote a CLAUDE.md holding only
`@AGENTS.md`. Every comparison now goes through realPath, and the setup
tests' scratch folders take its spelling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…ames its target once

The test now runs setup with the home folder as created and with its upper- and
lower-cased spellings where the file system holds them, so the ~/ import case
runs on Linux too and a lowercase drive letter is covered on Windows. The
check for a CLAUDE.md above the temporary folder walks the spelling the
scratch folders use. imports() resolves its target before reading the lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Claude Code knows its own CLAUDE.md by the spelling HOME or CLAUDE_CONFIG_DIR
gives it. Under another spelling (other letter case on macOS) it reads that
file as one above the checkout and leaves AGENTS.md unread, so the @AGENTS.md
import setup writes there is the one the client needs. agentsUnreadFor
compares that file by the spelling given again.

An import is read under any spelling of its path, so imports() still names
both sides as the file system does. The test pins both: another spelling of
the configuration folder gets the import, and a ~/ import under any spelling
counts as reading AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…pelling and follows a ~/ import

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 force-pushed the fix/agent-instructions-real-path branch from 6c7f7a4 to 4201571 Compare December 3, 2026 10:25
@zlareb1
zlareb1 marked this pull request as ready for review December 3, 2026 10:26
zlareb1 and others added 4 commits December 3, 2026 16:25
…, on every platform

clientSpelling (was real) keeps the spelling Claude Code knows its own
CLAUDE.md by, and the comment and the integration page name USERPROFILE
beside HOME. Both behaviour claims name the Claude Code version they were
checked on, 2.1.335.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
imports() takes the spelling it compares by. The repository's CLAUDE.md
compares its import as written (clientSpelling), so a file system that folds
letter case no longer moves the block: `@agents.md` beside AGENTS.md keeps
the block in CLAUDE.md on every machine. Files outside the checkout keep the
file system's spelling (realPath), whose docstring now names letter case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
asWritten (was clientSpelling) says what it returns; imports() takes its
spelling at both call sites, each with its reason. realPath folds letter case
on macOS and Windows only, and the integration page names the Claude Code
version the CLAUDE.md spelling was checked on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup counts Claude Code's own CLAUDE.md as the person's when its folder is spelled another way on Windows

1 participant